package com.lanchetech.user.controller;

import com.lanchetech.bean.request.MeetingPageReq;
import com.lanchetech.bean.request.MeetingUserPageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.MeetingUserVO;
import com.lanchetech.bean.vo.MeetingVO;
import com.lanchetech.entity.Meeting;
import com.lanchetech.entity.User;
import com.lanchetech.user.service.MeetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Api(value = "会场接口", tags = "会场接口")
@RequestMapping("/api/meeting")
@RestController
public class MeetingController {

    @Autowired
    MeetingService meetingService;

    @ApiOperation("编辑会场")
    @PostMapping("/editMeeting")
    public BaseResp editMeeting(@RequestBody Meeting req) {
        return meetingService.editMeeting(req);
    }

    @ApiOperation("获取会场详情")
    @GetMapping("/getMeetingDetail")
    public ResultData<MeetingVO> getMeetingDetail(@RequestParam("id") Long id) {
        return meetingService.getMeetingDetail(id);
    }

    @ApiOperation("删除会场")
    @GetMapping("/deleteMeeting")
    public BaseResp deleteMeeting(@RequestParam("id") Long id) {
        return meetingService.deleteMeeting(id);
    }

    @ApiOperation("获取我的会场分页")
    @PostMapping("/getMyMeetingPage")
    public ResultData<BasePageResp<MeetingVO>> getMyMeetingPage(@RequestBody MeetingPageReq req) {
        return meetingService.getMyMeetingPage(req);
    }

    @ApiOperation("获取会场分页")
    @PostMapping("/getMeetingPage")
    public ResultData<BasePageResp<MeetingVO>> getMeetingPage(@RequestBody MeetingPageReq req, @AuthenticationPrincipal User user) {
        return meetingService.getMeetingPage(req, user);
    }

    @ApiOperation("获取会场报名分页")
    @PostMapping("/getMeetingUserPage")
    public ResultData<BasePageResp<MeetingUserVO>> getMeetingUserPage(@RequestBody MeetingUserPageReq req) {
        return meetingService.getMeetingUserPage(req);
    }

    @ApiOperation("获取我的会场报名分页")
    @PostMapping("/getMyMeetingUserPage")
    public ResultData<BasePageResp<MeetingUserVO>> getMyMeetingUserPage(@RequestBody MeetingUserPageReq req) {
        return meetingService.getMyMeetingUserPage(req);
    }

    @ApiOperation("获取参加会场总次数")
    @GetMapping("/getJoinMeetCount")
    public ResultData<Long> getJoinMeetCount(@AuthenticationPrincipal User user) {
        return meetingService.getJoinMeetCount(user);
    }

    @ApiOperation("报名会场")
    @GetMapping("/joinMeeting")
    public BaseResp joinMeeting(@RequestParam("meetingId") Long meetingId) {
        return meetingService.joinMeeting(meetingId);
    }

    @ApiOperation("取消报名")
    @GetMapping("/cancelMeeting")
    public BaseResp cancelMeeting(@RequestParam("meetingId") Long meetingId) {
        return meetingService.cancelMeeting(meetingId);
    }

    @ApiOperation("核销报名用户")
    @GetMapping("/verifyConfirmMeetUser")
    public BaseResp verifyConfirmMeetUser(@RequestParam("hashId") String hashId, @RequestParam("meetingId") Long meetingId) {
        return meetingService.verifyConfirmMeetUser(hashId, meetingId);
    }

    @ApiOperation("获取报名用户详情")
    @GetMapping("/getMeetUserDetail")
    public ResultData<MeetingUserVO> getMeetUserDetail(@RequestParam("id") Long id) {
        return meetingService.getMeetUserDetail(id);
    }

}
